package com.ciban.smarthome.module.ui.base;

import com.ciban.smarthome.R;

import android.app.Fragment;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;

public class BaseFragment extends Fragment {

	public boolean delItem() {
		return true;
	}
	
	public void delCancle() {
	}

	protected PopupWindow menuPopWin;

	protected void showMenuWin(View v) {
		if (menuPopWin == null) {
			View view = View.inflate(getActivity(),
					R.layout.ppw_mode, null);

			TextView tv_add = (TextView) view.findViewById(R.id.mode_add);
			TextView tv_edit = (TextView) view.findViewById(R.id.mode_edit);

			tv_edit.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					editMode();
				}
			});
			tv_add.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					addMode();
				}
			});

			menuPopWin = new PopupWindow(view, 200, LayoutParams.WRAP_CONTENT);
			menuPopWin.setFocusable(true);
			menuPopWin.setBackgroundDrawable(getResources().getDrawable(
					R.mipmap.group_icon));
			menuPopWin.setOutsideTouchable(true);
		}
		if (!menuPopWin.isShowing())
			menuPopWin.showAsDropDown(v);
	}

	protected void addMode() {
	}

	protected void editMode() {
	}
}
